#encoding:utf-8
import apriori as ap
ds=ap.loadDataSet()
l,sup=ap.apriori(ds,minSupport=0.3)#若取值更小一些例如0.25产生的频繁项目集就会更多
rules=ap.generateRules(l,sup,minConf=0.7)#0.6
index=1
dic={}
for r in rules:
    temp=r[0]|r[1]
    dic[index]=temp
    index+=1

matrix={}
for i in dic.keys():
    sb=[]
    for j in dic.keys():
        if dic[i].issubset(dic[j]):
            sb.append(j)
    matrix[i]=sb

s=''
for k in matrix.keys():
    s=s+str(k)+':'+str(matrix[k])+'\n'

f=open('e:\\development\\SpaceRelation.txt','w')
f.write()
f.close()